<template>
  <div id="screen-wrap">
    <div class="big-screen" :style="{ transform: `scale(${scale})`, transformOrigin: '0 0' }">
      <div class="header">
        <div class="header-left">
          <div class="title">某公司大数据展示模板标题</div>
          <div class="tabbar">
            <div class="tab-item" v-for="item in tabBarList" :key="item.id">
              {{ item.label }}
            </div>
          </div>
        </div>
        <div class="time">
          {{ time }}
        </div>
      </div>
      <div class="screen-con">
        <div class="con-left">
          <CardModel title="销量排行榜"> </CardModel>
          <!-- <div class="left-top border">
          <div id="chart" style="height: 100%; width: 100%"></div>
        </div>
        <div class="left-bottom border">左下</div> -->
        </div>
        <div class="con-middle">
          <CardModel>
            <Map></Map>
          </CardModel>
          <!-- <div class="middle-top border">中上</div>
        <div class="middle-bottom border">中下</div> -->
        </div>
        <div class="con-right border">
          <!-- <div class="right-top border">右上</div>
        <div class="right-middle border">右中</div>
        <div class="right-bottom border">右下</div> -->
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue'
import dayjs from 'dayjs'
import CardModel from '@/components/CardModel.vue'
import Map from '@/components/chart/Map.vue'
const scale = ref(1)
const tabBarList = ref([
  { id: 1, label: '导航标题' },
  { id: 2, label: '导航标题' },
  { id: 3, label: '导航标题' },
  { id: 4, label: '导航标题' }
])
const time = ref(dayjs().format('YYYY-MM-DD HH:mm:ss'))
setInterval(() => {
  time.value = dayjs().format('YYYY-MM-DD HH:mm:ss')
}, 1000)
const setScale = () => {
  const height = document.getElementById('screen-wrap')?.clientHeight || 0
  const width = document.getElementById('screen-wrap')?.clientWidth || 0
  const zoomNum = Math.min(width / 1410, height / 740)
  console.log(zoomNum)
  scale.value = zoomNum
}
onMounted(() => {
  setScale()
  window.addEventListener('resize', setScale)
})
onUnmounted(() => {
  window.removeEventListener('resize', setScale)
})
</script>

<style scoped lang="scss">
#screen-wrap {
  height: calc(100% - 15px);
  width: 100%;
}
.border {
  border: 1px solid #fff;
}
.big-screen {
  background: url(@/assets/bg.png) no-repeat center;
  background-size: cover;
  padding: 0 10px;
  height: 740px;
  width: 1410px;
}
.header {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  .header-left {
    display: flex;
    align-items: center;
    .title {
      color: #dffcff;
      font-size: 24px;
      font-weight: bold;
    }
    .tabbar {
      display: flex;
      align-items: center;
      margin-left: 30px;
      .tab-item {
        margin-right: 15px;
      }
    }
  }
  .time {
    font-size: 10px;
  }
}
.screen-con {
  display: flex;
  height: 660px;
  width: 100%;
  .con-left {
    width: 300px;
    height: 100%;
    .left-top {
      height: 290px;
    }
  }
  .con-middle {
    width: 790px;
    height: 100%;
    margin: 0 10px;
  }
  .con-right {
    width: 300px;
    height: 100%;
  }
}
</style>
